<template>
  <view class="post-detail-page">
    <!-- 帖子标题 -->
    <view class="post-title">{{ detailData.name }}</view>
    <!-- 帖子信息（发布时间） -->
    <view class="post-info">
      <text>发布时间: {{ formmattedDate }}</text>
    </view>
    <!-- 帖子内容 -->
    <view class="section-title">帖子内容</view>
    <view class="post-content" v-html="detailData.content"></view>
    <!-- 帖子描述 -->
    <view class="section-title">帖子描述</view>
    <view class="post-content">{{ detailData.desc }}</view>


  </view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from "@dcloudio/uni-app";
import {getDetail} from '../../api/zixun.js'
import dayjs from 'dayjs';

let ZixunId = ref('');
let detailData = ref({});
let ceartTime = ref('');
const formmattedDate = ref('');
let name = ref('');
let pinglunValue = ref('');

onLoad((option) => {
  // 获取传递参数
  console.log(option.id);
  ZixunId.value=option.id
  getDetailFn()
});

// 获取详情
async function getDetailFn() {
  let r1 = await getDetail(ZixunId.value);
  console.log(r1.data.data);
  detailData.value = r1.data.data;
  // 将创建日期转化为年月日格式
  ceartTime.value = detailData.value.createdAt;
  formmattedDate.value = dayjs(ceartTime.value).format('YYYY-MM-DD HH:mm:ss');
}



</script>

<style scoped>
.post-detail-page {
  padding: 20px;
  background-color: #f9f9f9;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.post-title {
  font-size: 28px;
  font-weight: bold;
  color: #333;
  margin-bottom: 15px;
}

.post-info {
  font-size: 14px;
  color: #777;
  margin-bottom: 25px;
  display: flex;
  gap: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: #555;
  margin-bottom: 10px;
}

.post-content {
  font-size: 16px;
  line-height: 1.7;
  color: #444;
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

.comment-list-title {
  font-size: 22px;
  font-weight: bold;
  color: #333;
  margin-bottom: 15px;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

.comment-list {
  margin-bottom: 30px;
}

.comment-item {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 20px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.comment-author {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.comment-date {
  font-size: 12px;
  color: #999;
}

.comment-content {
  font-size: 14px;
  line-height: 1.6;
  color: #555;
}

.comment-input-section {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 20px;
}

.comment-input-section text {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
  display: block;
}

.pinglun {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.input-field {
  flex: 1;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}

.pinglun button {
  padding: 12px 20px;
  background-color: #007aff;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.pinglun button:hover {
  background-color: #0056b3;
}
</style>